package com.jinsi.service.yrf.iml;
import com.jinsi.mapper.yrf.OperationLogMapper;
import com.jinsi.pojo.OperationLog;
import com.jinsi.service.yrf.OperationLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class OperationLogServiceImpl implements OperationLogService {

    @Autowired
    private OperationLogMapper mapper;

    @Override
    public void addlog(String actionListName,String operationType,String operationRemarks) throws Exception {
        String administratorName = mapper.seluNameById(2);
        OperationLog ops = new OperationLog();
        ops.setActionListName(actionListName);
        ops.setOperationType(operationType);
        ops.setOperationRemarks(operationRemarks);
        ops.setAdministratorName(administratorName);
        int num = mapper.addlog(ops);
        if (num == 0){
            throw new Exception();
        }
    }

    @Override
    public List<OperationLog> getAll(String administratorName, String actionListName, String operationType, Date executionTime) {
        return mapper.getAll(administratorName,actionListName,operationType,executionTime);
    }

    @Override
    public void operationLogdelete(int operationLogId) {
        mapper.operationLogdelete(operationLogId);
    }


    @Override
    public void delAll(ArrayList<Integer> ops) {
        mapper.delAll(ops);
    }

}
